/**
 * 把UseGuard(AuthGuard('jwt'))简化 --> 封装装饰器 用于加入 鉴权/权限 验证
 */

import { applyDecorators, SetMetadata, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { Role } from '../enum';
import { RoleGuard } from '@/auth/guard/role.guard';

export function Auth(...roles: Role[]) {
  return applyDecorators(
    SetMetadata('roles', roles),
    UseGuards(AuthGuard('jwt'), RoleGuard),
  );
}
